package cn.qplanet.transaction.service;

import cn.qplanet.transaction.annotation.SecureInvoke;
import org.springframework.stereotype.Component;

import java.util.Random;

/**
 * @author: gjq0117
 * @date: 2024/5/12 13:59
 * @description:
 */
@Component
public class MqProduct {

    @SecureInvoke(async = false)
    public void sendMsg() {
        //1、假设发送消息有1/3的几率失败
        Random random = new Random();
        if (random.nextInt(3) > 3) {
            System.out.println("发送消息失败了");
            throw new RuntimeException("失败...");
        }
        System.out.println("发送消息");
    }
}
